﻿namespace MYThird
{
    internal class Program
    {/// <summary>
     /// moving word game
     /// </summary>
     /// <param name="args"></param>
        static void Main(string[] args)
        {   //初始位置（0，0）
            int x = 0, y = 0;
            //设置游戏的出口
            bool flag = true;
            while (flag)
            { //清空
                Console.Clear();
                //设置光标的位置
                Console.SetCursorPosition(x, y);
                //有个方便看到的东西
                Console.Write("hello");
                //读取所按的键，赋给direction
                char direction = Console.ReadKey(true).KeyChar;
                switch (direction)
                {
                    case 'a':
                    case 'A':
                        x = x - 1;
                        //小限制
                        if (x < 0)
                            x = 0;
                        break;
                    case 'd':
                    case 'D':
                        x = x + 1;
                        break;
                    case 'w':
                    case 'W':
                        y = y - 1;
                        if (y < 0)
                            y = 0;
                        break;
                    case 's':
                    case 'S':
                        y = y + 1;
                        break;
                    case 'q':
                    case 'Q':
                        flag = false;
                        Console.Clear();
                        Console.WriteLine("game over");
                        break;
                    default:
                        break;

                }
            }




        }
    }
}